home *** CD-ROM | disk | FTP | other *** search
- ************************************************************
- * *
- * GPL Subprogram >29 - Delete Subdirectory *
- * *
- * Date: January 12, 1996 *
- * Author: David Nieters *
- * *
- * Description: This subroutine will delete a *
- * subdirectory, but only if it is empty. *
- * *
- * Inputs: *
- * PATH - Contains parent directory (blank if in root) *
- * >834C - Unit Number *
- * >834E - Pointer to directory name *
- * *
- * Error Codes: *
- * 4 - Directory was not empty *
- * 6 - Device Error *
- * 7 - Directory does not exist *
- * *
- * Modifications: *
- * March 22, 1997 - Added code to delete FDIR also when *
- * deleting a directory *
- * *
- ************************************************************
-
- RMDIR0 ANDI R12,>FF00
- AI R12,24
-
- BL @MAKEFN
-
- * Append a period to the name
- *
- LDCR @B02,4
- LI R1,NCB
- RMDIR1 CB *R1+,@SPACE
- JNE RMDIR1
- DEC R1
- MOVB @PERIOD,*R1
- LDCR @B04,4
- MOVB @PERIOD,*R1
-
- * See if the directory exists
- *
- BL @GETDDR
- CI R5,0
- JNE RMDIR2 Directory does not exist
- MOVB @B07,@>8350 Set error code
- B @DSRRT
-
- * Directory exists - make sure it is empty
- *
- RMDIR2 LDCR @B03,4
- C @22(R5),@ZERO
- JEQ RMDIR3
- MOVB @B04,@>8350 Set error code
- B @DSRRT
-
- * Directory exists and is empty - delete it
- * Step 1: Remove the AU from the parent and decrement
- * the number of subdirectories counter
- * Step 2: Deallocate the AU formerly used by the deleted DDR
- * Step 3: Deallocate the AU of the FDIR
- *
-
- RMDIR3
- MOV @24(R5),R1 Get AU of FDIR
- LDCR @B02,4
- MOV R1,@MKDAU2 And save for later
-
- * We should invalidate the cache entry. Something like this
- * should do it -
- *
- LDCR @B04,4
- CLR *R4
-
- * LDCR @B04,4
- MOV @SAVEAU,R1 Get AU of DDR
- LDCR @B02,4
- MOV R1,@SFDRAU Save for later
-
- * Remove the last period from the file name and get the
- * parent DDR
- *
-
- LDCR @B02,4
- LI R1,NCB+39
- RMDIR4 CB *R1,@PERIOD
- JEQ RMDIR5
- DEC R1
- JMP RMDIR4
-
- RMDIR5 MOVB @SPACE,*R1
- LDCR @B04,4
- MOVB @SPACE,*R1
-
- BL @GETDDR
- LDCR @B02,4
- MOV @SFDRAU,R7
- LDCR @B03,4
-
- SB @B01,@23(R5) Decrement subdirectory counter
- MOV R5,R4
- AI R4,28
- RMDIR6 C R7,*R4+
- JNE RMDIR6
-
- AI R5,256 Now points to end of DDR
- MOV R4,R3
- DECT R3
- RMDIR7 MOV *R4+,*R3+
- C R4,R5
- JNE RMDIR7
- CLR *R3
- AI R5,-256
-
- * Now write DDR back out
- *
- LDCR @B04,4
- MOV @SAVEAU,R7 Get AU of parent DDR
- MOV R6,R3
- SRL R3,8
- SLA R3,1
- MPY @SAUTBL(R3),R7
-
- LI R1,SECBUF
- SRL R8,1
- JNC RMDR7A
- AI R1,>100
- RMDR7A SRL R7,1
- JNC RMDR7B
- AI R8,>8000
- RMDR7B
- LDCR @ZERO,4
- BLWP @BANKIT
- DATA SCSIRD
- JEQ RMDIR8
-
- RMDIRE MOVB @B06,@>8350
- B @DSRRT
-
- RMDIR8
- * Copy the new DDR and write it back out
- *
- LI R0,256
- RMDR8A LDCR @B03,4
- MOV *R5+,R2
- LDCR @ZERO,4
- MOV R2,*R1+
- DECT R0
- JNE RMDR8A
-
- BLWP @BANKIT
- DATA SCSIWT
- JNE RMDIRE
-
- * If we are writing out the VIB, we need to write
- * out the copy as well
-
- CI R7,0
- JNE RMDIR9
- CI R8,0
- JNE RMDIR9
- AI R8,16
- BLWP @BANKIT
- DATA SCSIWT
- JNE RMDIRE
- RMDIR9
- * Now deallocate the AU. If the DDR and FDIR are adjacent, we can
- * delallocate both AUs in one call. Otherwise, we have to make two
- * calls to DEALL.
-
- LDCR @B02,4
- MOV @SFDRAU,R7
- MOV @MKDAU2,R8
- MOV R8,R1
- DEC R1
- C R1,R7
- JEQ RMDR9A
-
- MOV R7,R8
- LDCR @ZERO,4
- BLWP @DEALL
-
- LDCR @B02,4
- MOV @MKDAU2,R7
- MOV R7,R8
- RMDR9A LDCR @ZERO,4
- BLWP @DEALL
-
- MOVB @ZERO,@>8350 Set success code
- B @DSRRT
-